asm
  ld sp,$43FF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $4010
dim seed as uinteger at $4012
dim ee0 as uinteger at $401C
dim ee1 as uinteger at $401E
dim ee2 as uinteger at $4014
dim ee3 as uinteger at $4016
dim ee4 as uinteger at $4018
dim ee5 as uinteger at $401A
dim ex0 as uinteger at $4020
dim ey0 as uinteger at $4022
dim ej0 as uinteger at $4024
dim ej1 as uinteger at $4026

seed=0

sub marinedateputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte):
  poke $4800+(31-typ1)+(txp1*32),tch1
  end sub

for ee1=0 to 31
  for ee0=0 to 31
    seed=smsrnd(seed)
    marinedateputchar(ee0,ee1,seed mod 8 )
    'marinedateputchar(ee0,ee1,96+(seed mod 9) )
    smsdelay(100)
    next:next

for ee1=0 to 15
  for ee0=0 to 15
    seed=smsrnd(seed)
    marinedateputchar(ee0+15,ee1+15,ee1*16+ee0 )
    smsdelay(100)
    next:next

'do
'for ee0=0 to 15
'ej0=in(ee0)
'marinedateputchar(6,2+ee0,48+((int(ej0/100)) mod 10))
'marinedateputchar(7,2+ee0,48+((int(ej0/10)) mod 10))
'marinedateputchar(8,2+ee0,48+(ej0 mod 10))
'next
'loop

'ee1=128
eee=0
do

ej0=in(0)
marinedateputchar(6,2,48+((int(ej0/100)) mod 10))
marinedateputchar(7,2,48+((int(ej0/10)) mod 10))
marinedateputchar(8,2,48+(ej0 mod 10))

ej0=in(1)
marinedateputchar(6,3,48+((int(ej0/100)) mod 10))
marinedateputchar(7,3,48+((int(ej0/10)) mod 10))
marinedateputchar(8,3,48+(ej0 mod 10))
ee1=ej0 bxor $FF

ej0=in(2)
marinedateputchar(6,4,48+((int(ej0/100)) mod 10))
marinedateputchar(7,4,48+((int(ej0/10)) mod 10))
marinedateputchar(8,4,48+(ej0 mod 10))

ej0=in(3)
marinedateputchar(6,5,48+((int(ej0/100)) mod 10))
marinedateputchar(7,5,48+((int(ej0/10)) mod 10))
marinedateputchar(8,5,48+(ej0 mod 10))

ej0=in(4)
marinedateputchar(6,6,48+((int(ej0/100)) mod 10))
marinedateputchar(7,6,48+((int(ej0/10)) mod 10))
marinedateputchar(8,6,48+(ej0 mod 10))

ej0=in(5)
marinedateputchar(6,7,48+((int(ej0/100)) mod 10))
marinedateputchar(7,7,48+((int(ej0/10)) mod 10))
marinedateputchar(8,7,48+(ej0 mod 10))

ej0=in(6)
marinedateputchar(6,8,48+((int(ej0/100)) mod 10))
marinedateputchar(7,8,48+((int(ej0/10)) mod 10))
marinedateputchar(8,8,48+(ej0 mod 10))

marinedateputchar(int(ee1/8),10,eee)

eee=eee+1
loop

do:loop

do

for ee1=0 to 31
  for ee0=0 to 31
    seed=smsrnd(seed)
    marinedateputchar(ee0,ee1,seed)
    smsdelay(1000)
    next:next

loop

for eee=$4800 to $4BFF
  seed=smsrnd(seed)
  poke eee,seed
  smsdelay(1000)
  next

do:loop


'static ADDRESS_MAP_START( marinedt_map, AS_PROGRAM, 8, marinedt_state )
'AM_RANGE(0x0000, 0x37ff) AM_ROM
'AM_RANGE(0x4000, 0x43ff) AM_RAM
'AM_RANGE(0x4400, 0x47ff) AM_RAM             //unused, vram mirror?
'AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(tx_tileram_w) AM_SHARE("tx_tileram")
'AM_RANGE(0x4c00, 0x4c00) AM_WRITENOP    //?? maybe off by one error
'ADDRESS_MAP_END

'static ADDRESS_MAP_START( marinedt_io_map, AS_IO, 8, marinedt_state )
'ADDRESS_MAP_GLOBAL_MASK(0xff)
'AM_RANGE(0x00, 0x00) AM_READ_PORT("DSW0")       //dips coinage
'AM_RANGE(0x01, 0x01) AM_READ(marinedt_port1_r)  //trackball xy muxed
'AM_RANGE(0x02, 0x02) AM_READWRITE(marinedt_obj1_x_r, marinedt_obj1_a_w)
'AM_RANGE(0x03, 0x03) AM_READ_PORT("IN0") AM_WRITE(marinedt_obj1_x_w)
'AM_RANGE(0x04, 0x04) AM_READ_PORT("DSW1") AM_WRITE(marinedt_obj1_y_w)
'AM_RANGE(0x05, 0x05) AM_WRITE(marinedt_music_w)
'AM_RANGE(0x06, 0x06) AM_READWRITE(marinedt_obj1_yr_r, marinedt_sound_w)
'AM_RANGE(0x08, 0x08) AM_WRITE(marinedt_obj2_a_w)
'AM_RANGE(0x09, 0x09) AM_WRITE(marinedt_obj2_x_w)
'AM_RANGE(0x0a, 0x0a) AM_READWRITE(marinedt_obj1_yq_r, marinedt_obj2_y_w)
'AM_RANGE(0x0d, 0x0d) AM_WRITE(marinedt_pd_w)
'AM_RANGE(0x0e, 0x0e) AM_READWRITE(marinedt_coll_r, watchdog_reset_w)
'AM_RANGE(0x0f, 0x0f) AM_WRITE(marinedt_pf_w)
'ADDRESS_MAP_END
















'sub chacknpopputsprite(tlayer as uinteger,txpos as ubyte,typos as ubyte,tid as ubyte,tclut as ubyte):
'  poke $9840+(tlayer*4),typos bxor $FF
'  poke $9841+(tlayer*4),tid
'  poke $9842+(tlayer*4),tclut
'  poke $9843+(tlayer*4),txpos
'  end sub
'
'
''-------------------------------------------------------------------------------
'
'for ee2=0 to 31
'  for ee3=0 to 31
'    chacknpopputchar(ee3,ee2,code("."))
'    next:next
'
'for ee2=0 to 15
'  for ee3=0 to 15
'    chacknpopputchar(ee3+14,ee2+12,ee3+(ee2*16))
'    next:next
'
'for eee=$9800 to $983F '- attr  64 bytes - ?????????????
'  for ee2=1 to 1000:next
'  seed=smsrnd(seed)
'  poke eee,seed
'  next
'
'for eee=$9840 to $98FF '- sprites - 192 bytes
'  poke eee,eee
'  next
'
'ex0=40:ey0=40
'eee=0
'
'do
'  ej0=peek($8809) bxor $FF
'  ej1=peek($880B) bxor $FF
'  chacknpopputchar(8,25,48+(ej0 mod 10))
'  chacknpopputchar(7,25,48+((int(ej0/10)) mod 10))
'  chacknpopputchar(6,25,48+((int(ej0/100)) mod 10))
'  chacknpopputchar(8,26,48+(ej1 mod 10))
'  chacknpopputchar(7,26,48+((int(ej1/10)) mod 10))
'  chacknpopputchar(6,26,48+((int(ej1/100)) mod 10))
'
'  for ee2=0 to 5
'    for ee3=0 to 7
'      chacknpopputsprite(ee3+(ee2*8),ex0+(ee3*16),ey0+(ee2*16),eee band 15,eee band 15)
'      next:next
'
'  ex0=ex0-((ej0 band 1)/1)+((ej0 band 2)/2)
'  ey0=ey0+((ej0 band 4)/4)-((ej0 band 8)/8)
'
'  eee=eee+1
'  for ee2=1 to 500:next
'  loop
'
'do:loop
'
'
